<?php

require_once(WSB_MODULES_PATH . 'sherpa/models/CategoryGateway.php');
require_once(WSB_MODULES_PATH . 'sherpa/models/ProductGateway.php');

class Sherpa_SubnavigationController extends WSB_Xtension_Navigation
{

	/**
	 * @return string
	 */
	public function renderForBackend()
	{
		return get_class($this);
	}

	/**
	 * Index Action
	 */
	public function indexAction()
	{
		$tree = WSB_Node_Page::getTree();
		$pageId = WSB_Frontend::getInstance()->getPageId();
		if($pageId > 0) {
			$branch = $tree->getBranch($pageId);
			if($branch->getLevel() == 2) {
				$branch = $branch->getParent();
				//$pageId = $branch->id;
			}
			if($branch->hasChildren()) {
				$this->_view->pageId = $pageId;
				$this->_view->branch = $branch;
				$this->addContent($this->_view->render('subnavigation/index.phtml'));
			}
		}
	}

}